Previous | Index | Next |

Output iterators

Output iterators must implement the methods defined in the interface OutputIterator api. These methods are summarized in the table below. Assume that r and s are output iterators and that v is a value of type Object.

Output Iterator Requirements
expression return type note
r.cmp(s) boolean compare two iterators
r.next() Iterator advance the iterator
r.put(v) Object deference the iterator

NOTE:Assignment through the same value of the iterator happens only once. Algorithms on output iterators should never attempt to pass through the same iterator twice. They should be single pass algorithms. Equality and inequality are not necessarily defined. Algorithms that take output iterators can be used with OutputStream as the destination for placing data through the OutputStreamIterator class as well as with insert iterators. In particular, the following two conditions should hold: first, any iterator value should be assigned through before it is incremented (this is, for an output iterator i,

    i.next();
    i.next();
is not a valid code sequence); second, any value of an output iterator may have at most one active copy at any given time (for example,
    i = j.copy();
    i.next();
    i.put(a);
    j.put(b);
is not a valid code sequence).


Previous | Index | Next |